import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['ytick.direction'] = 'in'

n = np.array([10, 20, 30, 40])
ave_t_lapack_dgemm = [1.2983e-05, 7.957e-06, 1.3763e-05, 1.8264e-05 ]
ave_t_cblas_dgemm = [3.572e-06, 7.814e-06, 1.3656e-05, 1.735e-05 ]
ave_t_hand_dgemm = [4.849e-06, 2.1208e-05, 5.6103e-05, 7.7626e-05 ]
ave_t_cblas_zgemm3m = [5.474e-06, 0.000102166, 4.761e-06, 8.797e-06 ]
ave_t_cblas_zgemm = [2.035e-06, 3.538e-06, 3.486e-06, 4.785e-06 ]
ave_t_hand_zgemm = [2.1615e-05, 7.665e-06, 2.4406e-05, 0.000282375 ]

plt.bar(n, ave_t_lapack_dgemm, label = "lapack_dgemm")
plt.bar(n+0.8, ave_t_cblas_dgemm, label = "cblas_dgemm")
plt.bar(n+1.6, ave_t_hand_dgemm,  label = "hand_dgemm")
plt.bar(n+2.4, ave_t_cblas_zgemm3m,  label = "cblas_zgemm3m")
plt.bar(n+3.2, ave_t_cblas_zgemm,  label = "cblas_zgemm")
plt.bar(n+4, ave_t_hand_zgemm, label = "hand_zgemm")

plt.xlabel("Dimension n")
plt.ylabel("t(s) of $A_{n x n}  B_{n x n}$")
plt.legend()
plt.subplots_adjust(left=0.2, right=0.9, top = 0.9, bottom=0.1)
plt.title("Benchmark matrix multiplication of small matrices")
#plt.xlim(0, 50); plt.ylim(-0.0001, 0.001)
plt.savefig("TimeMatrixMultiplication.jpg")
plt.show()
